using System;

namespace RedSkies
{
	public class LevelMapLoader
	{
		public LevelMapLoader ()
		{
			
		}
		
		
		
		public WorldMatrix CreateInitialLevelMapMatrix()
		{
			D2dMapLoader m= new D2dMapLoader(@"/Application/graphix/1.txt");
			
			WorldMatrix wm = new WorldMatrix((int)m.GetMapSize().X+1,(int)m.GetMapSize().Y+5,25);
			
			for(int x =0;x<m.GetMapSize().X;x++)
			{
				for(int y =0;y<m.GetMapSize().Y;y++)
				{
					byte b =  (byte) m.GetBlockID(y,x);
					if (b!=255)
					{
						wm[x,21-y] =b;
					}
				}
			}
			return wm;
			
			/*
			WorldMatrix wm = new WorldMatrix((960/25)*11,(int)((544/25)*1.5),25);
			
			Random r = new Random();
			
			
			for (int x=0;x<(960/25)*10;x++)
			{
				for (int y=0;y<(544/25);y++)
				{
					byte element = (byte) (r.NextDouble()*200);
					if (x > 2 && x< 12 )
					{
						wm[x,y] = 0; 	
					} else 
					if (y == 0)
					{
						if (x==12)
						{
							wm[x,y]=10;
						} else if (x>12){
							wm[x,y]=11;
						} else {
							wm[x,y] = (byte)((x%3) + 10); 	
						}
					} else
					if (y == 1)
					{
						if (x==12)
						{
							wm[x,y]=7;
						} else if (x>12){
							wm[x,y]=8;
						} else {
							wm[x,y] = (byte)((x%3) + 7); 	
						}
						
//						wm[x,y] = (byte)((x%3) + 7); 	
					} else
					if (y == 2)
					{
						if (x==12)
						{
							wm[x,y]=4;
						} else if (x>12){
							wm[x,y]=5;
						} else {
							wm[x,y] = (byte)((x%3) + 4); 	
						}
						
						//wm[x,y] = (byte)((x%3) + 4); 	
					} else
					if (y == 3)
					{
						if (x % 4 == 0)
						{
							wm[x,y] = 2; 	
						} else {
							wm[x,y] = 0;
						}
					} else 
					{
						if (element>199)
						{
							wm[x,y]=2;
						} else {
							wm[x,y] = 0;	
						}
					}					
				}
			}
			return wm;*/
			
		}
	}
}

